package cn.itcast.bos.mq;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;
@Service("smsConsumer")
public class SmsConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		// 调用SMS发送短信
		// String mas= SmsUtils.sendSmsByHTTP(mapMessage.getString("telephone"),
		// mapMessage.getString("msg"));
		String msg = "000/xxx";
		if (msg.startsWith("000")) {
			try {
				System.out.println("短信发送成功" + mapMessage.getString("telephone") + "验证码:" + mapMessage.getString("msg"));
			} catch (JMSException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {
			throw new RuntimeException("短信发送失败,信息码" + msg);
		}

	}

}
